<?php
//1."
class good
{
	private $name;
	private $price;
	private $amount;
	
	function __construct($n,$p,$a){
		$this->name = $n;
		$this->price = $p;
		$this->amount =$a;
		}
	
	function input($amount_,$amount,$add)
{
	$amount_=$amount+$add;
	echo "入库：$amount_";
	echo "<br>";
}
	function output($amount__,$amount,$out)
	{
		$amount__=$amount-$out;
		echo "出库：$amount__";
		echo "<br>";
	}
	function display(){
		echo "商品信息："."<br>";
		echo "名称：".$this->name."<br>";
		echo "价格：".$this->price."<br>";
		echo "库存:".$this->amount."<br>";
	}
}
$drink = new good("cola","3.5￥","100");
$drink->display();
$drink->input(200,100,100);
$drink->output(50,100,60);

//子类
class shoes extends good
{
	public $discount;
	public $discount_price;
	function __construct($dis,$dis_)
	{
		$this-> discount=$dis;
		$this-> discount_price=$dis_;
	}
	function display()
	{
		echo "折扣率：".$this-> discount."<br>";
		echo "折扣价：".$this-> discount_price."<br>";
	}
}
$cola=new shoes(0.8,2.8);
$cola->display();


echo "<br>";


//2.
class Fun
{
	function fun1(){
		echo "fun1"."<br>";
	}
	function fun2(){
		echo "fun2"."<br>";
	}
	function fun3(){
		echo "fun3"."<br>";
	}
	function fun4(){
		echo "fun4"."<br>";
	}
}//题目

class MyFun extends Fun
{
	function fun1()
	{
		echo "实现自己的功能"."<br>";
	}
	function fun2()
	{
		echo "fun2"."<br>";
		echo "增加一个功能"."<br>"; 
	}
	function fun3(){}
}
$my=new MyFun;
$my-> fun1();
$my-> fun2();
$my-> fun3();
$my-> fun4();



echo "<br>";


//3.
// 声明shape接口
interface shape
{
	 function square();
	 function volume();
     function shape_();
}

//实现接口
class point implements shape
{
	public $x;
	public $y;
	
	
	 function square(){}
	 function volume(){}
     function shape_(){}
	function display()
	{
		echo "面积：<br>";
		echo "体积:<br>";
	}
}

$sq =new point;
$sq -> display();


echo "<br>";


//4
class circle extends point {
	public $r;
	function __construct($R)
		{
			$this ->r = $R;
		}
	function square($sq){
		$sq=4*3.14*$R*$R;
		echo "$sq<br>";
	}
	function volume($v){
		$v=4/3*3.14*R*R*R;
		echo "$v<br>";
	}
    function shape_(){
    	echo "circle";
    }

 }


echo "<br>";
//5
class cylinder extends circle
{
	public $h;
	function __construct($r,$h)
  	{
  		$this->r=$r;
  		$this->h=$h;
  	}
  	function display()
  	{
  		echo "r:".$this->r."<br>";
  		echo "h:".$this->h."<br>";
  	}
	function square()
    {
    	$sq=(2*3.14*$this->r*$this->r)+(2*3.14*$this->r*$this->h);
    }
  
    function volume()
    {
      	$v=3.14*$this->r*$this->r*$this->h;

    }
  
}
$cy=new cylinder(1,1);
$cy->display();
$cy->area();
$cy->volum();
